/*   1:    */ package org.intellij.images.index;
/*   2:    */ 
/*   3:    */

import com.intellij.openapi.fileTypes.FileType;
import com.intellij.openapi.project.Project;
import com.intellij.openapi.vfs.VirtualFile;
import com.intellij.psi.search.GlobalSearchScope;
import com.intellij.util.indexing.*;
import com.intellij.util.indexing.FileBasedIndex.InputFilter;
import com.intellij.util.indexing.FileBasedIndex.ValueProcessor;
import com.intellij.util.io.DataExternalizer;
import com.intellij.util.io.DataInputOutputUtil;
import org.intellij.images.fileTypes.ImageFileTypeManager;
import org.intellij.images.util.ImageInfoReader;
import org.jetbrains.annotations.NotNull;

import java.io.DataInput;
import java.io.DataOutput;
import java.io.IOException;

/*   4:    */
/*   5:    */
/*   6:    */
/*   7:    */
/*   8:    */
/*   9:    */
/*  10:    */
/*  11:    */
/*  12:    */
/*  13:    */
/*  14:    */
/*  15:    */
/*  16:    */
/*  17:    */
/*  18:    */
/*  19:    */
/*  20:    */
/*  21:    */
/*  22:    */
/*  23:    */
/*  24:    */ 
/*  25:    */ public class ImageInfoIndex
/*  26:    */   extends SingleEntryFileBasedIndexExtension<ImageInfo>
/*  27:    */ {
/*  28:    */   private static final int a;
/*  29:    */   
/*  30:    */   static
/*  31:    */   {
/*  32: 38 */     int i = 200;
/*  33:    */     try
/*  34:    */     {
/*  35: 40 */       i = Integer.parseInt(System.getProperty("idea.max.image.filesize", Integer.toString(i)), 10);
/*  36:    */     }
/*  37:    */     catch (NumberFormatException localNumberFormatException) {}
/*  38: 42 */     a = i;
/*  39:    */   }
/*  40:    */   
/*  41: 45 */   public static final ID<Integer, ImageInfo> INDEX_ID = ID.create("ImageFileInfoIndex");
/*  42:    */   private final DataExternalizer<ImageInfo> b;
/*  43:    */   private final SingleEntryIndexer<ImageInfo> c;
/*  44:    */   
/*  45:    */   public ImageInfoIndex()
/*  46:    */   {
/*  47: 47 */     this.b = new DataExternalizer()
/*  48:    */     {
/*  49:    */       public void save(@NotNull DataOutput paramAnonymousDataOutput, ImageInfoIndex.ImageInfo paramAnonymousImageInfo)
/*  50:    */         throws IOException
/*  51:    */       {
/*  52: 50 */         if (paramAnonymousDataOutput == null) {
/*  53: 50 */           throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/images/index/ImageInfoIndex$1", "save" }));
/*  54:    */         }
/*  55: 50 */         DataInputOutputUtil.writeINT(paramAnonymousDataOutput, paramAnonymousImageInfo.width);
/*  56: 51 */         DataInputOutputUtil.writeINT(paramAnonymousDataOutput, paramAnonymousImageInfo.height);
/*  57: 52 */         DataInputOutputUtil.writeINT(paramAnonymousDataOutput, paramAnonymousImageInfo.bpp);
/*  58:    */       }
/*  59:    */       
/*  60:    */       public ImageInfoIndex.ImageInfo read(@NotNull DataInput paramAnonymousDataInput)
/*  61:    */         throws IOException
/*  62:    */       {
/*  63: 57 */         if (paramAnonymousDataInput == null) {
/*  64: 57 */           throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/images/index/ImageInfoIndex$1", "read" }));
/*  65:    */         }
/*  66: 57 */         return new ImageInfoIndex.ImageInfo(DataInputOutputUtil.readINT(paramAnonymousDataInput), DataInputOutputUtil.readINT(paramAnonymousDataInput), DataInputOutputUtil.readINT(paramAnonymousDataInput));
/*  67:    */       }
/*  68: 60 */     };
/*  69: 61 */     this.c = new SingleEntryIndexer(false)
/*  70:    */     {
/*  71:    */       protected ImageInfoIndex.ImageInfo computeValue(@NotNull FileContent paramAnonymousFileContent)
/*  72:    */       {
/*  73: 64 */         if (paramAnonymousFileContent == null) {
/*  74: 64 */           throw new IllegalArgumentException(String.format("Argument %s for @NotNull parameter of %s.%s must not be null", new Object[] { "0", "org/intellij/images/index/ImageInfoIndex$2", "computeValue" }));
/*  75:    */         }
/*  76: 64 */         ImageInfoReader.Info localInfo = ImageInfoReader.getInfo(paramAnonymousFileContent.getContent());
/*  77: 65 */         return localInfo != null ? new ImageInfoIndex.ImageInfo(localInfo.width, localInfo.height, localInfo.bpp) : null;
/*  78:    */       }
/*  79:    */     };
/*  80:    */   }
/*  81:    */   
/*  82:    */   @NotNull
/*  83:    */   public ID<Integer, ImageInfo> getName()
/*  84:    */   {
/*  85: 72 */     ID tmp3_0 = INDEX_ID;
/*  86: 72 */     if (tmp3_0 == null) {
/*  87: 72 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/images/index/ImageInfoIndex", "getName" }));
/*  88:    */     }
/*  89: 72 */     return tmp3_0;
/*  90:    */   }
/*  91:    */   
/*  92:    */   @NotNull
/*  93:    */   public SingleEntryIndexer<ImageInfo> getIndexer()
/*  94:    */   {
/*  95: 78 */     SingleEntryIndexer tmp4_1 = this.c;
/*  96: 78 */     if (tmp4_1 == null) {
/*  97: 78 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/images/index/ImageInfoIndex", "getIndexer" }));
/*  98:    */     }
/*  99: 78 */     return tmp4_1;
/* 100:    */   }
/* 101:    */   
/* 102:    */   public static void processValues(VirtualFile paramVirtualFile, FileBasedIndex.ValueProcessor<ImageInfo> paramValueProcessor, Project paramProject)
/* 103:    */   {
/* 104: 82 */     FileBasedIndex.getInstance().processValues(INDEX_ID, Integer.valueOf(Math.abs(FileBasedIndex.getFileId(paramVirtualFile))), paramVirtualFile, paramValueProcessor, GlobalSearchScope.fileScope(paramProject, paramVirtualFile));
/* 105:    */   }
/* 106:    */   
/* 107:    */   @NotNull
/* 108:    */   public DataExternalizer<ImageInfo> getValueExternalizer()
/* 109:    */   {
/* 110: 89 */     DataExternalizer tmp4_1 = this.b;
/* 111: 89 */     if (tmp4_1 == null) {
/* 112: 89 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/images/index/ImageInfoIndex", "getValueExternalizer" }));
/* 113:    */     }
/* 114: 89 */     return tmp4_1;
/* 115:    */   }
/* 116:    */   
/* 117:    */   @NotNull
/* 118:    */   public FileBasedIndex.InputFilter getInputFilter()
/* 119:    */   {
/* 120: 95 */     void tmp21_18 = new DefaultFileTypeSpecificInputFilter(new FileType[] { ImageFileTypeManager.getInstance().getImageFileType() });
/* 121: 95 */     if (tmp21_18 == null) {
/* 122: 95 */       throw new IllegalStateException(String.format("@NotNull method %s.%s must not return null", new Object[] { "org/intellij/images/index/ImageInfoIndex", "getInputFilter" }));
/* 123:    */     }
/* 124: 95 */     return tmp21_18;
/* 125:    */   }
/* 126:    */   
/* 127:    */   public int getVersion()
/* 128:    */   {
/* 129:107 */     return 5;
/* 130:    */   }
/* 131:    */   
/* 132:    */   public static class ImageInfo
/* 133:    */   {
/* 134:    */     public int width;
/* 135:    */     public int height;
/* 136:    */     public int bpp;
/* 137:    */     
/* 138:    */     public ImageInfo(int paramInt1, int paramInt2, int paramInt3)
/* 139:    */     {
/* 140:116 */       this.width = paramInt1;
/* 141:117 */       this.height = paramInt2;
/* 142:118 */       this.bpp = paramInt3;
/* 143:    */     }
/* 144:    */     
/* 145:    */     public boolean equals(Object paramObject)
/* 146:    */     {
/* 147:123 */       if (this == paramObject) {
/* 148:123 */         return true;
/* 149:    */       }
/* 150:124 */       if ((paramObject == null) || (getClass() != paramObject.getClass())) {
/* 151:124 */         return false;
/* 152:    */       }
/* 153:126 */       ImageInfo localImageInfo = (ImageInfo)paramObject;
/* 154:128 */       if (this.bpp != localImageInfo.bpp) {
/* 155:128 */         return false;
/* 156:    */       }
/* 157:129 */       if (this.height != localImageInfo.height) {
/* 158:129 */         return false;
/* 159:    */       }
/* 160:130 */       if (this.width != localImageInfo.width) {
/* 161:130 */         return false;
/* 162:    */       }
/* 163:132 */       return true;
/* 164:    */     }
/* 165:    */     
/* 166:    */     public int hashCode()
/* 167:    */     {
/* 168:137 */       int i = this.width;
/* 169:138 */       i = 31 * i + this.height;
/* 170:139 */       i = 31 * i + this.bpp;
/* 171:140 */       return i;
/* 172:    */     }
/* 173:    */   }
/* 174:    */ }



/* Location:           E:\idea\

 * Qualified Name:     org.intellij.images.index.ImageInfoIndex

 * JD-Core Version:    0.7.0.1

 */